package com.example.hometown_walker.exception;

import org.apache.commons.lang3.StringUtils;

/**
 * @description: 校验，不熔断
 * @author: chenchaoran
 * @date: 2020-04-02
 */
public class AssertUtil {

    public static void isTrue(Boolean expression, String errorMsg) {
        if (!expression) {
            throw new ServiceException(errorMsg);
        }
    }

    public static void nonNull(Object o, String errorMsg) {
        if (o == null) {
            throw new ServiceException(errorMsg);
        }
    }

    public static void nonBlank(String text, String errorMsg) {
        if (StringUtils.isBlank(text)) {
            throw new ServiceException(errorMsg);
        }
    }

}
